/**
 * 
 */
$(document).ready(function() {
	
	//获取用户id
	var id = window.parent.document.getElementsByClassName("handler")[0].id;
	$(".toOrderInfo").click(function(){
		window.location.href="initOrderInfo?id="+$(this).parent().parent().attr("id");
	})
	
	var startDate = $("#startDate").val();
	var endDate = $("#endDate").val();
	var state = $("#state").val();
	//搜索查询
	$("#search").click(function(){
		startDate = $("#startDate").val();
		endDate = $("#endDate").val();
		state = $("#state").val();
		var pageSize = $('#pageSize').val();
		window.location.href="jumpMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state
		+"&pageSize="+pageSize+"&currentPage=0";
		//window.location.href="initMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state;
	})
	
	//点击下一页
	$("#nextPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		var currentPage = $('#currentPage').html();
		var totalPage = $('#totalPage').html();
		if(currentPage == totalPage){
			return ;
		}
		startDate = $("#startDate").val();
		endDate = $("#endDate").val();
		state = $("#state").val();
		window.location.href="jumpMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state
		+"&pageSize="+pageSize+"&currentPage="+currentPage;
    });  
	//点击上一页
	$("#parentPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		var currentPage = $('#currentPage').html();
		if(currentPage == 1){
			return ;
		}
		startDate = $("#startDate").val();
		endDate = $("#endDate").val();
		state = $("#state").val();
		window.location.href="jumpMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state
		+"&pageSize="+pageSize+"&currentPage="+(currentPage-2);
    }); 
	//点击首页
	$("#firstPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		startDate = $("#startDate").val();
		endDate = $("#endDate").val();
		state = $("#state").val();
		window.location.href="jumpMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state
		+"&pageSize="+pageSize+"&currentPage=0";
    }); 
	
	//点击尾页
	$("#lastPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		startDate = $("#startDate").val();
		endDate = $("#endDate").val();
		state = $("#state").val();
		var totalPage = $('#totalPage').html();
		window.location.href="jumpMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state
		+"&pageSize="+pageSize+"&currentPage="+(totalPage-1);
    }); 
	
	//页面大小
	$("#pageSize").change(function(){ 
		var pageSize = $('#pageSize').val();
		startDate = $("#startDate").val();
		endDate = $("#endDate").val();
		state = $("#state").val();
		window.location.href="jumpMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state
		+"&pageSize="+pageSize+"&currentPage=0";
	});
	
	//跳转
	$("#selectPage").change(function(){ 
		var pageSize = $('#pageSize').val();
		startDate = $("#startDate").val();
		endDate = $("#endDate").val();
		state = $("#state").val();
		var jumpPage = $("#selectPage option:selected").val();
		window.location.href="jumpMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state
		+"&pageSize="+pageSize+"&currentPage="+(jumpPage-1);
	});
});
